package com.example.common.file;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class FileOperationService {
    public static void processFiles(File source, File target) {
        try {
            if (FileCompareUtil.areFilesEqual(source, target)) {
                Files.delete(source.toPath());
                System.out.println("文件内容相同，已删除源文件：" + source.getName());
            } else {
                FileMergeUtil.mergeFiles(source, target);
                System.out.println("文件内容不同，已合并至：" + target.getName());
            }
        } catch (IOException e) {
            throw new RuntimeException("文件操作失败：" + e.getMessage(), e);
        }
    }
}